#include <rtthread.h>
#include "app.h"

#define DBG_TAG "app"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>



void APP_SysInitialize(void)
{
    BQ769X0_InitDataTypeDef InitData;
	
	InitData.AlertOps.scd = BMS_ProtectHwSCD;
	InitData.AlertOps.ocd = BMS_ProtectHwOCD;
	InitData.AlertOps.ov = BMS_ProtectHwOV;
	InitData.AlertOps.uv = BMS_ProtectHwUV;
	InitData.AlertOps.device = BMS_ProtectHwDevice;
	InitData.AlertOps.ovrd = BMS_ProtectHwOvrd;
	

    InitData.ConfigData.SCDDelay = INIT_SCD_DELAY;
    InitData.ConfigData.OCDDelay = INIT_OCD_DELAY;
    InitData.ConfigData.OVDelay = INIT_OV_DELAY;
    InitData.ConfigData.UVDelay = INIT_UV_DELAY;

    InitData.ConfigData.SCDThresh = SCD_THRESH_89mV_44mV;
    InitData.ConfigData.OCDThresh = OCD_THRESH_22mV_11mV;
    InitData.ConfigData.OVThresh = INIT_OV_PROTECT * 1000;
    InitData.ConfigData.UVThresh = INIT_UV_PROTECT * 1000;

	I2C_BusInitialize();
    BQ769X0_Initialize(&InitData);
	
	BMS_MonitorInit();
	BMS_AnalysisInit();
	BMS_ProtectInit();
	BMS_EnergyInit();
	BMS_InfoInit();
}
